local skel = fk.CreateSkill{
  name = "divine_weapon_skill",
}
Fk:loadTranslationTable{
  ["divine_weapon_skill"] = "神兵",
  [":divine_weapon_skill"] = "神兵",
  ["#divine_weapon_skill"] = "选择弃置所有装备牌或铠甲合体",
  ["divine_weapon_1"] = "卸甲！",
  ["divine_weapon_2"] = "铠甲合体",
}
---@type CardSkillSpec
local laying_down = {
  prompt = "#divine_weapon_skill",
  can_use = Util.GlobalCanUse,
  on_use = function (self, room, cardUseEvent)
    local choice = room:askToChoice(cardUseEvent.from, {
      choices = { "divine_weapon_1", "divine_weapon_2" },
      skill_name = skel.name,
      prompt = "#divine_weapon_skill",
      cancelable = false,
    })
    cardUseEvent.extra_data = cardUseEvent.extra_data or {}
    cardUseEvent.extra_data.divine_weapon_choice = choice
    return Util.AoeCardOnUse(self, cardUseEvent.from, cardUseEvent, true)
  end,
  mod_target_filter = Util.TrueFunc,
  about_to_effect = function (self, room, effect)
    local use = effect.use or {}
    use.extra_data = use.extra_data or {}
    local choice = use.extra_data.divine_weapon_choice
    if choice == "divine_weapon_1" and #effect.to:getCardIds("e") == 0 then
      return true
    elseif choice == "divine_weapon_2" and #effect.to:getAvailableEquipSlots() == 0 then
      return true
    end
  end,
  on_effect = function(self, room, effect)
    local to = effect.to
    local use = effect.use or {}
    use.extra_data = use.extra_data or {}
    local choice = use.extra_data.divine_weapon_choice
    if to.dead then return end
    if choice == "divine_weapon_1" then
      to:throwAllCards("e", skel.name)
    else
      for _, i in ipairs(to:getAvailableEquipSlots()) do
        for _, e in ipairs(room.draw_pile) do
          if to.dead then goto END_EFFECT end
          if Fk:getCardById(e).type == Card.TypeEquip and Fk:getCardById(e).sub_type == Util.convertSubtypeAndEquipSlot(i) and not to:prohibitUse(Fk:getCardById(e)) then
            local usecard = { ---@type UseCardDataSpec
              from = to,
              tos = { to },
              card = Fk:getCardById(e),
            }
            room:useCard(usecard)
            break
          end
        end
        room:delay(500)
      end
    end
    ::END_EFFECT::
  end,
}
skel:addEffect("cardskill", laying_down)
return skel